/*   Copyright © 2009 Mark Gil Torres
 *
 *   This file is part of mtoolkit.
 *
 *   mtoolkit is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *
 *   mtoolkit is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with mtoolkit.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef VARIABLE_HPP
#define VARIABLE_HPP

#include <string>
#include <vector>
#include "q.hpp"

namespace mt {

  template <typename T> class Variable;
  template <typename T> bool operator==(Variable<T> const& inValue1, Variable<T> const& inValue2);

  template <typename T = Q<int> >
  class Variable {
    public:
      Variable(void);
      Variable(std::string const& inValue1, T const& inValue2);
      Variable(std::string const& inValue1, T const& inValue2, std::string const& inValue3);
      Variable(Variable<T> const& inValue);

      Variable& operator=(Variable<T> const& inValue);

      std::string& getName(void);
      std::string& getSubscript(void);
      T& getExponent(void);

      void setName(std::string const& inValue);
      void setSubscript(std::string const& inValue);
      void setExponent(T const& inValue);

      friend bool operator== <>(Variable<T> const& inValue1, Variable<T> const& inValue2);

      bool isEqual(Variable<T> const& inValue);
    private:
      std::string name;
      std::string subscript;
      T exponent;
  };

//constructors
  template <typename T>
  Variable<T>::Variable(void) {
    name = "NULL";
    subscript = "NULL";
    exponent = 0;
  }

  template <typename T>
  Variable<T>::Variable(std::string const& inValue1, T const& inValue2) {
    name = inValue1;
    subscript = "NULL";
    exponent = inValue2;
  }

  template <typename T>
  Variable<T>::Variable(std::string const& inValue1, T const& inValue2, std::string const& inValue3) {
    name = inValue1;
    subscript = inValue3;
    exponent = inValue2;
  }

  template <typename T>
  Variable<T>::Variable(Variable<T> const& inValue) : name(inValue.name), subscript(inValue.subscript), exponent(inValue.exponent) {}

//assignment operator
  template <typename T>
  Variable<T>& Variable<T>::operator=(Variable<T> const& inValue) {
    name = inValue.name;
    subscript = inValue.subscript;
    exponent = inValue.exponent;
  }

//getter
  template <typename T>
  std::string& Variable<T>::getName(void) {
    return name;
  }

  template <typename T>
  std::string& Variable<T>::getSubscript(void) {
    return subscript;
  }

  template <typename T>
  T& Variable<T>::getExponent(void) {
    return exponent;
  }

//setter
  template <typename T>
  void Variable<T>::setName(std::string const& inValue) {
    name = inValue;
  }

  template <typename T>
  void Variable<T>::setSubscript(std::string const& inValue) {
    subscript = inValue;
  }

  template <typename T>
  void Variable<T>::setExponent(T const& inValue) {
    exponent = inValue;
  }

  template <typename T>
  bool Variable<T>::isEqual(Variable<T> const& inValue) {
    if (name == inValue.name && subscript == inValue.subscript && exponent == inValue.exponent) return true;
    return false;
  }

  template <typename T>
  bool operator==(Variable<T> const& inValue1, Variable<T> const& inValue2) {
    std::string name_iv1 = inValue1.name;
    std::string name_iv2 = inValue2.name;
    std::string sub_iv1 = inValue1.subscript;
    std::string sub_iv2 = inValue2.subscript;
    T exp_iv1 = inValue1.exponent;
    T exp_iv2 = inValue2.exponent;
    if (name_iv1 == name_iv2 && sub_iv1 == sub_iv2 && exp_iv1 == exp_iv2) return true;
    return false;
  }



}

#endif
